<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="../common/common.jsp"%>
<title>版块修改</title>
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form" action="" method="post">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>apiUrl：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${mailConfig.apiUrl}" placeholder="" id="apiUrl" name="apiUrl" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>apiUser：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${mailConfig.apiUser}" id="apiUser" name="apiUser" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>apiKey：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${mailConfig.apiKey}" placeholder="" id="apiKey" name="apiKey" required="true">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>mailFrom：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="${mailConfig.mailFrom}" placeholder="" id="mailFrom" name="mailFrom" required="true">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-8 col-xs-offset-4 col-sm-offset-3">
                <button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
            </div>
        </div>
    </form>
</article>

<script type="text/javascript">
$(document).ready(function(){
	 var id = "${id}";
	 $('#form').bind('submit', function () {
		var apiUrl = $("#apiUrl").val();
		var apiUser = $("#apiUser").val();
		var apiKey = $("#apiKey").val();
		var mailFrom = $("#mailFrom").val();
		$.ajax({
			type : 'POST',
			url : ctx + '/emailConfigManage/updateEmailConfig.do',
			data : {
				id : id,
				apiUrl : apiUrl,
				apiUser : apiUser,
				apiKey : apiKey,
				mailFrom : mailFrom
			},
			dataType : 'json',
			timeout : 30000,
			context : $('body'),
			success : function(data) {
				if (data.code == "ok") {
					 layer.msg("保存成功!", {icon: 6, time: 1000}, function () {
						 layer_close();
	                    });
				} else {
					 layer.msg(data.msg, {icon: 5, time: 2000});
				}
			},
			error : function(xhr, type) {
				layer.msg('保存失败!', {icon: 5, time: 2000});
			}
		});
		return false;
	 });
});
</script>
</body>
</html>